function start() {
	$("#last").load("../footer.html #footer1");
	var myUserName = "myUserName";
	var myPwd = "myPwd"
	var isLogin = "isLogin";
	var isbuy = "isbuy";
	var goodMessage = "goodMessage";
	//判断用户是否登陆
	doesLogin();
	function doesLogin() {
		if (getCookie(isLogin) == 1) {
			$(".header-center-right").find("li").eq(0).find("a").html('欢迎您,' + getCookie(myUserName));
			$(".header-center-right").find("li").eq(1).find("a").html('|&nbsp;<a href="javascript:void(0)" id="cancel">退出</a>')
		} else {
			$(".header-center-right").find("li").eq(0).find("a").html('<a href="registerlogin/login.html">[请登录]</a>');
			$(".header-center-right").find("li").eq(1).find("a").html('<a href="registerlogin/register.html">[快速注册]</a>');
		}
		$("#cancel").on("click", function() {
			if (getCookie(isLogin) == 1) {
				updateCookie(isLogin, "0");
				window.location = "index.html"
			}
		})
	}
	//没有商品跟有商品切换
	showgood();
	function showgood(){
		if(getCookie(isbuy) == 1){
			$(".havegoods").show();
			$(".nogoods").hide();
			addGoods2List();
		}else{
			$(".havegoods").hide();
			$(".nogoods").show();
		}
	}
	//去空格
	String.prototype.nospace = function(){
		return this.replace(/^\s+$/,'');
	}
	function addGoods2List(){
//		console.log(getCookie(goodMessage).split('-'))
//		var shopArr = getCookie(goodMessage).split('-');
//		
//		for(var i=0; i<shopArr.length; i++){
//			var a = shopArr[i].substring(1,shopArr[i].length-1);
//			console.log(eval(a))
//		}
		
		
		var goodMessages = JSON.parse(getCookie(goodMessage));
		console.log(goodMessages.img)
		var danjia = Number(goodMessages.goodprise.substring(2));
		var jianshu = Number(goodMessages.buynum);
		$(".btnshop_right").find("i").html("￥"+jianshu*danjia+".00");
		$(".goodsprise").html("￥"+jianshu*danjia+".00");
		$(".goodsprisea").html("￥"+jianshu*danjia+".00");
		
		//生成商品列表
		$(".showgoods").append('<li><div class="goodsnews"><div class="goodsimg"><a href="../goodsdetail/goodsdetail.html"><img src="'+
		goodMessages.img+'"/></a></div><a class="goodsword" href="../goodsdetail/goodsdetail.html">'+
		goodMessages.goodname+'</a></div><div class="goodsprise">'+
		goodMessages.goodprise+'</div><div class="buynum"><span class="jian"><img src="../img/det05.gif" alt="" /></span><input class="mainumum" type="text" value="'+
		goodMessages.buynum+'"/><span class="add"><img src="../img/det07.gif" alt="" /></span></div><div class="addprise">￥'+
		danjia*jianshu+'.00</div><div class="control"><a class="add2shoucang" href="javascript:void(0)">加入收藏夹</a><br><a class="deletegoods" href="javascript:void(0)">删除</a></div></li>')
		
		$(".add").on("click",function(){
			var num = parseInt($(".mainumum").val())+1;
			$(".mainumum").val(num);
			$(".addprise").html("￥"+num*danjia+".00");
			$(".btnshop_right").find("i").html("￥"+num*danjia+".00")
			$(".goodsprisea").html("￥"+num*danjia+".00");
		});
		$(".jian").on("click",function(){
			var num = parseInt($(".mainumum").val())-1;
			if(num <= 1){
				num = 1;
			}
			$(".mainumum").val(num);
			$(".addprise").html("￥"+num*danjia+".00");
			$(".btnshop_right").find("i").html("￥"+num*danjia+".00")
			$(".goodsprisea").html("￥"+num*danjia+".00");
		});
		$(".deletegoods").on('click',function(){
//			console.log(getCookie(goodMessage))
			$(".showgoods").remove();
			deleteCookie(goodMessage);
			updateCookie(isbuy,0,5)
			$(".havegoods").hide();
			$(".nogoods").show();
		});
		//去结算
		jieS();
		function jieS(){
		$(".jiesuan").on("click",function(){
				var goods = {
					img: $(".goodsnews").find(".goodsimg").find("img").attr("src"),
					goodname: $(".goodsnews").find(".goodsword").html(),
					goodnum: $(".goodsnews").find(".goodsnum").html(),
					goodprise:$(".goodsprise").html(),
					buynum: $(".mainumum").val()
				}
				var strgoods = JSON.stringify(goods);
				addCookie(goodMessage,strgoods,5);
				$(".jiesuan").html("正在结算..");
				console.log(getCookie(goodMessage))
				setTimeout(function(){
					window.location = "../orderpay/orderpay.html";
				},2000)
		})
	}
	};
	
	
	
}




$(function() {
	start();
})